package com.easyweb.session;

import com.easyweb.entity.*;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.persistence.EntityManager;

@Name("bolumList")
public class BolumList extends EntityQuery<Bolum> {

	@In private EntityManager entityManager;
	private List<Bolum> bolumListesi=null;
	private static final String EJBQL = "select bolum from Bolum bolum";

	private static final String[] RESTRICTIONS = {
			"lower(bolum.bolumAdi) like lower(concat(#{bolumList.bolum.bolumAdi},'%'))",
			"lower(bolum.bolumKodu) like lower(concat(#{bolumList.bolum.bolumKodu},'%'))", };

	private Bolum bolum = new Bolum();

	public BolumList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public Bolum getBolum() {
		return bolum;
	}

	public void bolumListesiOlustur(){
		bolumListesi=new ArrayList<Bolum>();
		bolumListesi=entityManager.createNamedQuery("bolumTumList").getResultList();
	}
	public List<Bolum> getBolumListesi() {
		if (bolumListesi==null) bolumListesiOlustur();
		return bolumListesi;
	}

	public void setBolumListesi(List<Bolum> bolumListesi) {
		this.bolumListesi = bolumListesi;
	}
}
